// pages/dgameques/dgameques.js
var poid,randid,openid,acid,sitetype
var pointmsg
Page({

   /**
   * 页面的初始数据
   */
  data: {
    modalHidden:true,
    success:'',
    score:'',
    // success:true
  },
  onLoad: function (options) {
    pointmsg = wx.getStorageSync('pointmsg')
    this.setData({score:pointmsg.Score})

    // pid是序号，通过的关卡数
    poid = options.pid
    randid = options.randid
    sitetype = options.sitetype
    openid = wx.getStorageSync('openid')
    acid = wx.getStorageSync('acidacid')
    var pointmsg = wx.getStorageSync('pointmsg')
    if(randid==undefined){
      randid = 0
    }
    console.log('randid',randid)
    console.log('结算页面参数，跳转的路标文件后缀',poid)
    if(poid==''||poid==undefined||poid=='undefined'){
      poid=1
    }
    if(options.state==0){
      this.setData({success:false})
      wx.request({
        url: 'https://www.juquduo.com/juquduo/gaming/privy/mistake',
        data:{
          activityId:acid,
          openid:openid,
          pointName:pointmsg.BranchName
        },
        success(res){
          console.log('失误点的序号',pointmsg.BranchName,res)
        }
      })
    }
    if(options.state==1){
      this.setData({success:true})
      wx.request({
        url: 'https://www.juquduo.com/juquduo/gaming/privy/record',
        data:{
          // openid:'oQUXz5IDxMpQcBvHaUayzE7Hy0R0',
          openid:openid,
          activityId:acid,
          pointName:pointmsg.BranchName,
          randId:randid,
          score:pointmsg.Score
        },
        success(res){
          console.log('答对的序号',pointmsg.BranchName,res)
        }
      })
    }
    console.log('success的参数',this.data.success)
    wx.setNavigationBarTitle({
      title: '正在游戏',
    })
    

  },

  onReady: function () {
    
  },
  
  //点击继续游戏
  continue:function(){
    this.setData({success:'2'})
  },

  toctn(){
    // sitetype='tree',sitetype = 1，sitetype为1，为树形点位
    if(sitetype=='1'){
      var pointmsg = wx.getStorageSync('pointmsg')
      // sitetype等于1是主线，跳转加载模型，否则开始下一关
      if(pointmsg.BranchId=='1'){
        this.setData({modalHidden:false})
      }else{
        wx.redirectTo({
          url: '../dgame1/dgame1',
        })
      }
    }
    if(sitetype=='2'){
      this.setData({modalHidden:false})
    }
  },
  opencamera(){
    wx.redirectTo({
      url: '../dsearch/search?randid='+ randid+'&sitetype='+sitetype+'&poid='+poid,poid
    })
  },
  share(){
    wx.showToast({
      title: '已分享',
    })
  }
})